package com.web.new12306.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.web.new12306.mvc.InnerDispatcherController;
import com.web.new12306.pojo.Order;
import com.web.new12306.pojo.PageOrderByCaiyan;
import com.web.new12306.service.OrderServiceByCaiyan;
import com.web.new12306.service.impl.OrderServiceImplByCaiyan;
public class OrderControllerByCaiyan extends InnerDispatcherController {
	/**
	 * @author 蔡艳
	 */
	private static final long serialVersionUID = -8128936181765400012L;
	
	public void pageGatagridOrder(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");
		Integer page = Integer.valueOf(request.getParameter("page"));
		Integer rows = Integer.valueOf(request.getParameter("rows"));
		Integer startrow=(page-1)*rows;
		System.out.println("page:" + page + ";rows:" + rows);
		OrderServiceByCaiyan os=new OrderServiceImplByCaiyan();
		List<Order> data =os.queryOrders(page, rows);
		int number=os.number();
		System.out.println(number);
		PageOrderByCaiyan page2=new PageOrderByCaiyan();
		page2.setTotal(number);
		page2.setRows(data);
		
		response.setContentType("application/json");
		response.getWriter().append(JSON.toJSONString(page2));
		System.out.println(JSON.toJSONString(page2));
	}
	
	

}